<?php

include 'source/define.php';
include ROOT_PATH . 'source/mysql_connect.php';
$TITLE = "Каталог товаров &bull; " . $TITLE;
$prod = array();
$categories = mysql_select_array("SELECT * FROM `category` WHERE `active`=1 ORDER BY `priority` ASC");
foreach ($categories as $key_cat => $category) {
    $products[$category['id']] = mysql_select_array("SELECT * FROM `product` WHERE `category_id` = ? AND `active` = 1", $category['id']);
    foreach ($products[$category['id']] as $key => $product) {
        $products[$category['id']][$key]['logo'] = mysql_value("SELECT `path` FROM `img` WHERE `prod_id` =? AND `logo` = 1", $product['id']);
        $products[$category['id']][$key]['description'] = preg_replace('#(\s\S+)$#ims', '', trim($product['summary']));
    }
}
include ROOT_PATH . "templates/header.php";
include ROOT_PATH . "templates/listing.php";
include ROOT_PATH . "templates/footer.php";